<!--事件流水-->
<template>
  <div class="common-body-wrapper">
    <search-header
      single-width="130"
      :searchList="searchList"
      @changeHeight="toRetTable"
      @confirmSearch="toSearch"
      :isNeedTree="true"
      :isCheckbox="true"
      @setSelectedNode="setSelectedNode"
      :paramName="paramName"
    ></search-header>
    <div class="common-table-tree-wrapper">
      <div class="common-table-wrapper">
        <multi-fun-table
          :sortColumn="notFormatColumn"
          :orderType="sortType"
          :fixed-cols="fixedCols"
          :is-reset-table="isResetTable"
          :theads-info="theadsInfo"
          :tbodys-info="tbodysInfo"
          @handleMultiCheck="handleMultiCheck"
          @handleSortColumn="handleSortColumn"
          @searchFn="getList"
          @getNextPage="getNextPage"
        >
          <!--按钮-->
          <div class="operate-btn-group" slot="operateBtnGroup">
            <a class="ake_btn ake_btn_text" @click.prevent="exportData()">导出</a>
            <a
              class="ake_btn ake_btn_text"
              v-if="isPermmited('MOBILE:EVNET:SETTYPE')"
              @click.prevent="typeModal_open()"
            >事件类型设置</a>
          </div>
          <template slot="tdCell" slot-scope="props">
            <el-table-column
              :fixed="props.fixed"
              :label="props.label"
              :min-width="props.minWidth"
              :width="props.width"
              :prop="props.prop"
              :sortable="props.sortable"
            >
              <template slot-scope="scope">
                <span v-if="'reno' == props.prop">{{scope.$index+1}}</span>
                <span v-else-if="'imgUrlList' == props.prop">
                  <span v-for="(item,index) in scope.row.imgUrlList" class="carNoImage" :key="item">
                    <span v-if="0 == index">
                      <a class="imgLink" @click="showPicModal('picModal', scope.row.imgUrlList)">
                        <img
                          class="carNoImage"
                          style="width: 60px;height:30px;"
                          alt="暂无"
                          :src="item"
                        />
                      </a>
                    </span>
                  </span>
                </span>
                <span v-else>{{ scope.row[props.prop] }}</span>
              </template>
            </el-table-column>
          </template>
        </multi-fun-table>

        <table-pagination :size="total" :cur-page="pageNumber" @backData="getPagination"></table-pagination>
      </div>
    </div>

    <!-- <big-pic-modal ref="bigPicModal">
      <img slot="bigImgSlot" :src="bigImgPath | setImgPath" alt="" @error="imgError('../../', 'car', $event)">
    </big-pic-modal>-->

    <basic-modal ref="picModal" width="700" customeClass="pic-modal" static="true">
      <h3 slot="title"></h3>
      <div class="modal-body" slot="modal-body">
        <el-carousel :interval="5000" arrow="always" height="300px">
          <el-carousel-item v-for="(item,index) in picPath" :key="item">
            <img :src="item" alt />
          </el-carousel-item>
        </el-carousel>
      </div>
    </basic-modal>

    <!--此处推荐：为每个modal创建顶级对象selfmodal，以便通过设置:model='selfModal'逐层找到相应的prop-->
    <basic-modal ref="typeModal" width="700" customeClass="type-modal" static="true">
      <h3 slot="title">事件类型设置</h3>
      <div class="modal-body" slot="modal-body">
        <el-form ref="type_form" :model="eventTypeInfo" label-position="left" label-width="80px">
          <template v-for="(listItem,index) in eventTypeInfoItems">
            <!--此处不进行eventType校验-->
            <div :key="index">
              <el-form-item :label="'类型'+(index+1)">
                <div class="colBox">
                  <el-input class="first-item" :value="listItem.eventType" disabled="disabled"></el-input>
                  <el-button
                    size="small"
                    type="primary"
                    v-if="true"
                    class="el-icon-delete"
                    @click.prevent="typeModal_del_open(index)"
                  ></el-button>
                </div>
              </el-form-item>
            </div>
          </template>
          <el-form-item
            prop="eventType"
            label="类型"
            :rules="{ min: 2, max: 15, message: '长度在 2 到 15 个字符', trigger: 'blur' }"
          >
            <div class="colBox">
              <el-input class="first-item" v-model="eventTypeInfo.eventType"></el-input>
              <el-button
                size="small"
                type="primary"
                class="el-icon-plus"
                @click="typeModal_save('type_form')"
              ></el-button>
            </div>
          </el-form-item>
        </el-form>
      </div>
      <div class="modal-footer" slot="modal-footer">
        <button class="ake_btn ake_btn_text ake_btn_confirm" @click.stop="submitTypeForm()">保存</button>
        <button class="ake_btn ake_btn_text" @click="closed('typeModal')">取消</button>
      </div>
    </basic-modal>

    <!--至少选择一项  modal-->
    <basic-modal ref="repeatTipModal" bodyTxt="事件类型重复">
      <h3 slot="title">温馨提示</h3>
      <div class="modal-footer" slot="modal-footer">
        <button class="ake_btn ake_btn_text modal-close" @click="closed('repeatTipModal')">关闭</button>
      </div>
    </basic-modal>

    <basic-modal ref="voidTipModal" bodyTxt="事件类型为空">
      <h3 slot="title">温馨提示</h3>
      <div class="modal-footer" slot="modal-footer">
        <button class="ake_btn ake_btn_text modal-close" @click="closed('voidTipModal')">关闭</button>
      </div>
    </basic-modal>

    <!--确认删除吗？  modal-->
    <basic-modal ref="delConfirmTipModal" bodyTxt="确认删除吗？">
      <h3 slot="title">温馨提示</h3>
      <div class="modal-footer" slot="modal-footer">
        <button class="ake_btn ake_btn_text ake_btn_confirm" @click="typeModal_del(delNo)">确定</button>
        <button class="ake_btn ake_btn_text modal-close" @click="closed('delConfirmTipModal')">关闭</button>
      </div>
    </basic-modal>
  </div>
</template>

<script>
import common from "@mixins/common.js";
import stardardList from "@mixins/tables/stardardList.js";

//modal
import invokeModal from "@mixins/modal/invokeModal.js";
import BigPicModal from "@components/widgets/BigPicModal.vue";

//image
import images from "@mixins/image.js";

// 引进vue的js
import event from "./js/event.js";

export default {
  name: "mobileEvent",
  mixins: [common, stardardList, invokeModal, images, event],
  components: {
    BigPicModal
  },
  data() {
    const today = [
      new Date(moment().format("YYYY-MM-DD 00:00:00")),
      new Date(moment().format("YYYY-MM-DD 23:59:59"))
    ];
    return {
      paramName: 'parkIds',
      total: 0,
      fixedCols: 3,
      typeInfo: [],
      searchList: [
        {
          type: "datePicker",
          isShow: false,
          name: "query_time",
          text: "事件时间",
          propName: "createTimeFrom,createTimeTo",
          value: today,
          style: { width: "360px" }
        },
        {
          index: 0,
          isShow: false,
          type: "text",
          name: "code",
          text: "事件编号",
          value: ""
        },
        {
          index: 1,
          isShow: false,
          type: "text",
          name: "userName",
          text: "现场管理员",
          value: ""
        },
        {
          type: "select",
          isShow: false,
          name: "eventTypeId",
          text: "事件类型",
          value: "",
          options: []
        },
        {
          index: 2,
          isShow: false,
          type: "text",
          name: "carCode",
          text: "车牌号",
          value: ""
        },
        {
          index: 4,
          isShow: false,
          type: "text",
          name: "eventContent",
          text: "事件内容",
          value: ""
        },
        {
          type: "select",
          isShow: false,
          name: "eventStatus",
          text: "状态",
          value: "",
          options: [
            { name: "全部", value: "" },
            { name: "暂未通知", value: "0" },
            { name: "通知车主", value: "1" },
            { name: "通知失败", value: "2" },
            { name: "仅作记录", value: "3" }
          ]
        }
      ],
      theadsInfo: [
        // { index: 0, isShow: false, prop: "reno", text: "序号", width: 68 },
        {
          index: 1,
          isShow: false,
          prop: "code",
          text: "事件编号",
          minWidth: 50,
          initHidden: true
        },
        {
          index: 2,
          isShow: false,
          prop: "userName",
          text: "现场管理员",
          minWidth: 50
        },
        {
          index: 3,
          isShow: false,
          prop: "phone",
          text: "管理员手机号码",
          minWidth: 60,
          initHidden: true
        },
        {
          index: 4,
          isShow: false,
          prop: "carCode",
          text: "车牌号",
          minWidth: 60
        },
        {
          index: 5,
          isShow: false,
          prop: "ownerPhone",
          text: "车主手机号",
          minWidth: 60
        },
        {
          index: 6,
          isShow: false,
          prop: "eventTypeStr",
          text: "事件类型",
          minWidth: 50
        },
        {
          index: 7,
          isShow: false,
          prop: "createTime",
          text: "事件时间",
          minWidth: 80
        },
        {
          index: 7,
          isShow: false,
          prop: "imgUrlList",
          text: "图片",
          minWidth: 60,
          initHidden: true
        },
        {
          index: 7,
          isShow: false,
          prop: "eventContent",
          text: "事件内容",
          minWidth: 60,
          initHidden: true
        },
        {
          index: 7,
          isShow: false,
          prop: "eventStatusStr",
          text: "状态",
          minWidth: 50
        }
      ],
      tbodysInfo: []
    };
  },
  methods: {}
};
</script>

<style lang="less">
.user-row-modal {
  .first-item {
    width: 240px;
  }
}

//调整transfer的样式
.type-modal {
  .modal-body {
    padding: 40px 36px;
    .colBox {
      display: flex;
      align-items: center;
      a {
        color: #337ab7;
        text-decoration: none;
        margin-left: 10px;
      }
      button {
        margin-left: 10px;
      }
    }
  }
  .el-checkbox + .el-checkbox {
    margin-left: 0;
  }
  .el-button + .el-button {
    margin-left: 0;
  }
}

.role-select {
  width: 240px;
}

.pic-modal {
  .modal-body {
    .el-carousel__item h3 {
      color: #475669;
      font-size: 18px;
      opacity: 0.75;
      line-height: 300px;
      margin: 0;
    }

    .el-carousel__item:nth-child(2n) {
      background-color: #99a9bf;
    }

    .el-carousel__item:nth-child(2n + 1) {
      background-color: #d3dce6;
    }
  }
}
.el-carousel__container {
  img {
    height: 100%;
    width: 100%;
  }
}
</style>
